﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterRevenueMS.Domain.Common.Models;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace WaterRevenueMS.Domain.ViewModels.BasicSet.RuleOfCode
{
    public class RuleOfCodeModel : EntityCommon
    {
        public RuleOfCodeModel()
        {
            Search = new SearchModel();
            RuleTypes = new List<SelectListItem>
            {
                new SelectListItem{Text="无效规则",Value="0"},
                new SelectListItem{Text="用户编号编码规则",Value="1"},
                new SelectListItem{Text="水表编号编码规则",Value="2"}
            };
            RuleItems = new List<SelectListItem>
            {
                new SelectListItem{Text="无规则,手工输入",Value="0"}
            };
            Yong_HBHCD = 11;
            Qu_YDMCD = 2;
            Biao_CDMCD = 4;
            Zi_ZBHCD = 5;
            Zi_ZBHZL = 1;
            Shui_BHCD = 1;
            Bian_MGZDY = 0;
        }

        public int Id { get; set; }

        [Display(Name="规则名称")]
        [Required(ErrorMessage="规则名称不能为空")]
        [StringLength(16,ErrorMessage="规则名称不能大于{1}个字符")]
        public string Bian_MGZ { get; set; }

        [Display(Name="规则类型")]
        public byte Bian_MDX { get; set; }
        public List<SelectListItem> RuleTypes { get; set; }

        public byte DefaultValue { get; set; }

        public int OrderNo { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name="用户编码长度")]
        public byte Yong_HBHCD { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "区域代码长度")]
        public byte Qu_YDMCD { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "表册代码长度")]
        public byte Biao_CDMCD { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "自增编号长度")]
        public byte Zi_ZBHCD { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "自增编号增量")]
        public byte Zi_ZBHZL { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "水表号长度")]
        public byte Shui_BHCD { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Display(Name = "编码规则定义")]
        public byte Bian_MGZDY { get; set; }
        public List<SelectListItem> RuleItems { get; set; }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        //自增最大值
        public long Auto_Num { get; set; }

        public SearchModel Search { get; set; }
    }
    public class SearchModel
    {
        public SearchModel()
        {

        }

        [Display(Name = "规则名称")]
        public string Bian_MGZ { get; set; }
    }
}
